<style>
	.view-9812321 .c-panel .el-form .el-input{width: 250px;}
</style>

<template>
	<div class="vue-box view-9812321">
		<div class="c-panel">
			<!-- 参数栏 -->
			<div class="c-title">修改物业信息</div>
			<el-form size="mini" v-if="m">
				<el-form-item label="物业名称：">
					<el-input v-model="m.property_name"></el-input>
				</el-form-item>
				<el-form-item label="详情描述：">
					<el-input v-model="m.property_details"></el-input>
				</el-form-item>
				<el-form-item label="物业抽成：">
					<el-input v-model="m.property_share" type="number" disabled></el-input>
				</el-form-item>
				
	
				<!-- <el-form-item label="开关参数：">
					<el-switch v-model="m.property_softdel" :active-value="1" :inactive-value="0" inactive-color="#ff4949"></el-switch>
					<span style="color: #999;" v-if="m.property_softdel==1">正常</span>
					<span style="color: #999;" v-else>禁用</span>
				</el-form-item> -->
				
				<el-form-item label="  ">
					<el-button type="primary"  @click="ok()">确定</el-button>
					<el-button type="primary"  @click="no()">取消</el-button>
				</el-form-item>
			</el-form>
		</div>
	</div>
</template>

<script>
	import mockJoptions from './mock-joptions.js';
	export default {
		data() {
			return {
				m: {	// 查询参数 
					name: '',
					count: '',
					create_time: '',
					type_id: 0,
					jvalue: [],
					single: 1,
					checkbox_1: true,
					checkbox_2: true,
					checkbox_3: false,
					checkbox_4: false,
					status: 1,
					hValue: 1,
					color: '#409EFF'
				}, 
				typeList: [		// 类型数组  
					{id: 1, name: '类型1'}, 
					{id: 2, name: '类型2'}, 
					{id: 3, name: '类型3'}, 
					{id: 4, name: '类型4'}, 
				],
				joptions: mockJoptions
			}
		},
		methods: {
			// 表单验证  
			submit_check: function() {
				var m = this.m;
				if(this.sa.isNull(m.property_name)) {
					return this.sa.error('请输入物业名称');
				}
				if(this.sa.isNull(m.property_details)) {
					return this.sa.error('请输入详情描述');
				}
				if(m.property_share == 0||m.property_share == '') {
					return this.sa.error('请输入物业抽成');
				}

				let reg1=/^[\u4e00-\u9fa5]+$/ ;
                if(!reg1.test(this.m.property_name)){
                    return this.sa.error2('物业名称格式错误');
				}

                

				return 'ok';
			},
			// 提交 
			ok: function() {
				if(this.submit_check() != 'ok') {
					return;
				}
				
				this.sa.ajax(
						'/e-administrator/property/addProperty',
							{
							propertyName:this.m.property_name,
							propertyDetails:this.m.property_details,
							propertyShare:this.m.property_share,
                            propertySoftdel:this.m.property_softdel
							}, 
						function(res){
						
						if(res.data){
								this.sa.ok('添加成功');	
							}else{
								this.sa.ok('添加失败');	
							}

							// this.propertyList = res.data;	// 数据
							// this.dataCount = res.dataCount;	// 分页
						}.bind(this),
					{type:'post'},
					);
					
				// this.sa.alert('提交参数为：' + JSON.stringify(this.m));
			},
		},
		created: function(){
			this.$notify.info({
				title: '消息',
				message: '本页面展示提交表单时各种常见的各种姿势'
			});
		}
	}
</script>
